﻿#include "GUI.h"
#include "DIALOG.h"
#include "CreateWidget.h"
#include "AppFunction.h"
#include "Common.h"
#include "common_path.h"



PARA_TCB home_widget[16];
extern PARA_TCB  setting_widget[16];
extern PARA_TCB  timer_widget[18];
extern PARA_TCB  curtain_widget[7];
extern PARA_TCB  temp_widget[5];
extern PARA_TCB  dimmer3c_widget[5];
extern PARA_TCB  music_widget[5];
extern PARA_TCB  password_widget[20];




void home_widget_create(WM_HWIN hParent){

	home_widget[0].guiTCB.winType     = WIDGET_WINDOW;
	AddStringToBuffer(home_widget[0].guiTCB.winName, "主页");
	home_widget[0].guiTCB.xPos        = 0;
	home_widget[0].guiTCB.yPos        = 0;
	home_widget[0].guiTCB.xSize       = 720;
	home_widget[0].guiTCB.ySize       = 720;
	home_widget[0].appTCB.funType     = WINDOW_NONE;
	home_widget[0].appTCB.addrList    = 0;
	home_widget[0].guiTCB.id          = GetUniqueID();
	home_widget[0].pPreviousLayer     = NULL;
	home_widget[0].pNextLayer         = NULL;
	home_widget[0].pParallelNext      = &home_widget[1];
	home_widget[0].parent             = hParent;
	home_widget[0].winLayer           = 1;
	home_widget[0].transparency       = 1;
	SetPictureHmem(&home_widget[0], 0, 0, GetPicturePathHmem(I_DTA_PATH_BGHOME));
	//SetPictureHmem(&home_widget[0], 0, 0, GetPicturePathHmem(I_DTA_3X4));

	home_widget[1].guiTCB.winType     = WIDGET_STATIC_TEXT;
	//strcat(home_widget[1].guiTCB.winName, "");
	home_widget[1].guiTCB.xPos        = 240;
	home_widget[1].guiTCB.yPos        = 40;
	home_widget[1].guiTCB.xSize       = 240;
	home_widget[1].guiTCB.ySize       = 60;
	home_widget[1].appTCB.funType     = TIME_FUNCTION + JUMP_TO_WINDOW;
	home_widget[1].appTCB.addrList    = 0;
	home_widget[1].guiTCB.id          = GetUniqueID();
	home_widget[1].guiTCB.pFont = &GUI_FONT_64;
	home_widget[1].pPreviousLayer     = NULL;
	home_widget[1].pNextLayer         = &timer_widget[0];
	home_widget[1].pParallelNext      = &home_widget[2];
	home_widget[1].parent             = NULL;



	home_widget[2].guiTCB.winType = WIDGET_BUTTON;
	AddStringToBuffer(home_widget[2].guiTCB.winName, "回家模式");
	home_widget[2].guiTCB.xPos = 500;
	home_widget[2].guiTCB.yPos = 250;
	home_widget[2].guiTCB.xSize = 200;
	home_widget[2].guiTCB.ySize = 170;
	home_widget[2].appTCB.funType = SWITCH_ACTUATOR;
	home_widget[2].appTCB.addrList = 0;
	home_widget[2].guiTCB.id = GetUniqueID();
	home_widget[2].pPreviousLayer = NULL;
	home_widget[2].pNextLayer = NULL;
	home_widget[2].pParallelNext = &home_widget[3];
	home_widget[2].parent = NULL;
	sprintf(home_widget[2].guiTCB.onPath, "%s", DTA_MODE_BACKHOME_ON);
	sprintf(home_widget[2].guiTCB.offPath, "%s", DTA_MODE_BACKHOME_OFF);


	home_widget[3].guiTCB.winType = WIDGET_BUTTON;
	AddStringToBuffer(home_widget[3].guiTCB.winName, "测试入口");;
	home_widget[3].guiTCB.xPos = 500;
	home_widget[3].guiTCB.yPos = 490;
	home_widget[3].guiTCB.xSize = 200;
	home_widget[3].guiTCB.ySize = 170;
	home_widget[3].appTCB.funType = JUMP_TO_WINDOW;
	home_widget[3].appTCB.addrList = 0;
	home_widget[3].guiTCB.id = GetUniqueID();
	home_widget[3].pPreviousLayer = NULL;
	home_widget[3].pNextLayer = &password_widget[0];
	home_widget[3].pParallelNext = &home_widget[4];
	home_widget[3].parent = NULL;
	sprintf(home_widget[3].guiTCB.onPath, "%s", DTA_MODE_AWAYHOME_ON);
	sprintf(home_widget[3].guiTCB.offPath, "%s", DTA_MODE_AWAYHOME_OFF);

	//home_widget[2].guiTCB.winType     = WIDGET_STATIC_TEXT;
	//AddStringToBuffer(home_widget[2].guiTCB.winName, "温控");
	//home_widget[2].guiTCB.xPos        = 532;
	//home_widget[2].guiTCB.yPos        = 220;
	//home_widget[2].guiTCB.xSize       = 144;
	//home_widget[2].guiTCB.ySize       = 100;
	//home_widget[2].appTCB.funType     = JUMP_TO_WINDOW;
	//home_widget[2].appTCB.addrList    = 0;
	//home_widget[2].guiTCB.id          = GetUniqueID();
	//home_widget[2].pPreviousLayer     = NULL;
	//home_widget[2].pNextLayer         = &temp_widget[0];
	//home_widget[2].pParallelNext      = &home_widget[3];
	//home_widget[2].parent             = NULL;


	//home_widget[3].guiTCB.winType     = WIDGET_STATIC_TEXT;
	//AddStringToBuffer(home_widget[3].guiTCB.winName, "灯光");
	//home_widget[3].guiTCB.xPos        = 532;
	//home_widget[3].guiTCB.yPos        = 350;
	//home_widget[3].guiTCB.xSize       = 144;
	//home_widget[3].guiTCB.ySize       = 100;
	//home_widget[3].appTCB.funType     = JUMP_TO_WINDOW;
	//home_widget[3].appTCB.addrList    = 0;
	//home_widget[3].guiTCB.id          = GetUniqueID();
	//home_widget[3].pPreviousLayer     = NULL;
	//home_widget[3].pNextLayer         = &dimmer3c_widget[0];
	//home_widget[3].pParallelNext      = &home_widget[4];
	//home_widget[3].parent             = NULL;


	home_widget[4].guiTCB.winType     = WIDGET_STATIC_TEXT;
	AddStringToBuffer(home_widget[4].guiTCB.winName, "0");
	home_widget[4].guiTCB.xPos        = 310;
	home_widget[4].guiTCB.yPos		  =	150;
	home_widget[4].guiTCB.xSize       = 2;
	home_widget[4].guiTCB.ySize       = 2;
	home_widget[4].appTCB.funType     = SWITCH_ACTUATOR;
	home_widget[4].appTCB.addrList    = 0;
	home_widget[4].guiTCB.id          = GetUniqueID();
	home_widget[4].pPreviousLayer     = NULL;
	home_widget[4].pNextLayer         = NULL;
	home_widget[4].pParallelNext      = &home_widget[5];
	home_widget[4].parent             = NULL;



	home_widget[5].guiTCB.winType     = WIDGET_STATIC_TEXT;
	//AddStringToBuffer(home_widget[5].guiTCB.winName, "窗帘");
	home_widget[5].guiTCB.xPos        = 716;
	home_widget[5].guiTCB.yPos        = 716;
	home_widget[5].guiTCB.xSize       = 2;
	home_widget[5].guiTCB.ySize       = 2;
	home_widget[5].appTCB.funType     = JUMP_TO_WINDOW;
	home_widget[5].appTCB.addrList    = 0;
	home_widget[5].guiTCB.id          = GetUniqueID();
	home_widget[5].pPreviousLayer     = NULL;
	home_widget[5].pNextLayer         = &curtain_widget[0];
	home_widget[5].pParallelNext      = &home_widget[6];
	home_widget[5].parent             = NULL;



	home_widget[6].guiTCB.winType     = WIDGET_BUTTON;
	home_widget[6].guiTCB.xPos        = 20;
	home_widget[6].guiTCB.yPos        = 20;
	home_widget[6].guiTCB.xSize       = 64;
	home_widget[6].guiTCB.ySize       = 64;
	home_widget[6].appTCB.funType     = IO_BUTTON_SENSOR;
	home_widget[6].appTCB.addrList    = 0;
	home_widget[6].guiTCB.id          = GetUniqueID();
	home_widget[6].pPreviousLayer     = NULL;
	home_widget[6].pNextLayer		  = NULL;
	home_widget[6].pParallelNext      = &home_widget[7];
	home_widget[6].parent             = NULL;
	sprintf(home_widget[6].guiTCB.onPath, "%s", DTA_HOME_ALARM);
	sprintf(home_widget[6].guiTCB.offPath, "%s", DTA_HOME_ALARM);



	home_widget[7].guiTCB.winType     = WIDGET_BUTTON;
	//home_widget[7].guiTCB.winName   = "设置";
	home_widget[7].guiTCB.xPos        = 600;
	home_widget[7].guiTCB.yPos        = 20;
	home_widget[7].guiTCB.xSize       = 120;
	home_widget[7].guiTCB.ySize       = 120;
	home_widget[7].appTCB.funType     = JUMP_TO_WINDOW;
	home_widget[7].appTCB.addrList    = 0;
	home_widget[7].guiTCB.id          = GetUniqueID();
	home_widget[7].pPreviousLayer     = NULL;
	home_widget[7].pNextLayer		  = setting_widget;
	home_widget[7].pParallelNext      = &home_widget[8];
	home_widget[7].parent             = NULL;
	sprintf(home_widget[7].guiTCB.onPath, "%s", DTA_HOME_SET);
	sprintf(home_widget[7].guiTCB.offPath, "%s", DTA_HOME_SET);



	home_widget[8].guiTCB.winType     = WIDGET_BUTTON;
	AddStringToBuffer(home_widget[8].guiTCB.winName, "回家模式");
	//strcat(home_widget[8].guiTCB.winName, "回家模式");
	home_widget[8].guiTCB.xPos        = 20;
	home_widget[8].guiTCB.yPos        = 250;
	home_widget[8].guiTCB.xSize       = 200;
	home_widget[8].guiTCB.ySize       = 170;
	home_widget[8].appTCB.funType	  = SWITCH_ACTUATOR;
	home_widget[8].appTCB.addrList    = 0;
	home_widget[8].guiTCB.id          = GetUniqueID();
	home_widget[8].pPreviousLayer     = NULL;
	home_widget[8].pNextLayer         = NULL;
	home_widget[8].pParallelNext      = &home_widget[9];
	home_widget[8].parent             = NULL;
	sprintf(home_widget[8].guiTCB.onPath, "%s", DTA_MODE_BACKHOME_ON);
	sprintf(home_widget[8].guiTCB.offPath, "%s", DTA_MODE_BACKHOME_OFF);



	home_widget[9].guiTCB.winType     = WIDGET_BUTTON;
	AddStringToBuffer(home_widget[9].guiTCB.winName, "离家模式");
	//strcat(home_widget[9].guiTCB.winName, "离家模式");
	home_widget[9].guiTCB.xPos        = 260;
	home_widget[9].guiTCB.yPos        = 250;
	home_widget[9].guiTCB.xSize       = 200;
	home_widget[9].guiTCB.ySize       = 170;
	home_widget[9].appTCB.funType     = SWITCH_ACTUATOR;
	home_widget[9].appTCB.addrList    = 0;
	home_widget[9].guiTCB.id          = GetUniqueID();
	home_widget[9].pPreviousLayer     = NULL;
	home_widget[9].pNextLayer         = NULL;
	home_widget[9].pParallelNext      = &home_widget[10];
	home_widget[9].parent             = NULL;
	sprintf(home_widget[9].guiTCB.onPath, "%s", DTA_MODE_AWAYHOME_ON);
	sprintf(home_widget[9].guiTCB.offPath, "%s", DTA_MODE_AWAYHOME_OFF);


	home_widget[10].guiTCB.winType    = WIDGET_BUTTON;
	AddStringToBuffer(home_widget[10].guiTCB.winName, "会客模式");
	//strcat(home_widget[10].guiTCB.winName, "会客模式");
	home_widget[10].guiTCB.xPos       = 20;
	home_widget[10].guiTCB.yPos       = 490;
	home_widget[10].guiTCB.xSize      = 200;
	home_widget[10].guiTCB.ySize      = 170;
	home_widget[10].appTCB.funType    = SWITCH_ACTUATOR;
	home_widget[10].appTCB.addrList   = 0;
	home_widget[10].guiTCB.id         = GetUniqueID();
	home_widget[10].pPreviousLayer    = NULL;
	home_widget[10].pNextLayer        = NULL;
	home_widget[10].pParallelNext     = &home_widget[11];
	home_widget[10].parent            = NULL;
	sprintf(home_widget[10].guiTCB.onPath, "%s", DTA_MODE_MEETING_ON);
	sprintf(home_widget[10].guiTCB.offPath, "%s", DTA_MODE_MEETING_OFF);


	home_widget[11].guiTCB.winType    = WIDGET_BUTTON;
	AddStringToBuffer(home_widget[11].guiTCB.winName, "休闲模式");
	//AddStringToBuffer(home_widget[11].guiTCB.winName, "4x4");
	home_widget[11].guiTCB.xPos       = 260;
	home_widget[11].guiTCB.yPos       = 490;
	home_widget[11].guiTCB.xSize      = 200;
	home_widget[11].guiTCB.ySize      = 170;
	home_widget[11].appTCB.funType    = SWITCH_ACTUATOR;
	home_widget[11].appTCB.addrList   = 0;
	home_widget[11].guiTCB.id         = GetUniqueID();
	home_widget[11].pPreviousLayer    = NULL;
	home_widget[11].pNextLayer        = NULL;
	home_widget[11].pParallelNext	  = &home_widget[12];
	home_widget[11].parent			  = NULL;
	sprintf(home_widget[11].guiTCB.onPath, "%s", DTA_MODE_COFFEE_ON);
	sprintf(home_widget[11].guiTCB.offPath, "%s", DTA_MODE_COFFEE_OFF);


	home_widget[12].guiTCB.winType    = WIDGET_STATIC_TEXT;
	strcat(home_widget[12].guiTCB.winName, "");
	home_widget[12].guiTCB.xPos       = 240;
	home_widget[12].guiTCB.yPos       = 100;
	home_widget[12].guiTCB.xSize      = 240;
	home_widget[12].guiTCB.ySize      = 60;
	//home_widget[12].guiTCB.pFont    = &GBK_24m24;
	home_widget[12].appTCB.funType    = DATE_FUNCTION + JUMP_TO_WINDOW;
	home_widget[12].appTCB.addrList   = 0;
	home_widget[12].guiTCB.id         = GetUniqueID();
	home_widget[12].pPreviousLayer    = NULL;
	home_widget[12].pNextLayer        = &timer_widget[0];
	home_widget[12].pParallelNext     = NULL;
	home_widget[12].parent            = NULL;

	SetHomePage(home_widget);
	CreateWidget(&home_widget[0], hParent, 1);
}